package data;

import javax.media.opengl.GL;

import logic.Visualization;

/**
 * radial layout rings
 * @author Fennes
 *
 */
public class Rings implements Drawable {

	private Vector3 color;
	private static int ringNumber = 3;
	/**
	 * rings with color black
	 */
	public Rings()
	{
		this.color = new Vector3(1.0f, 1.0f, 1.0f);
	}

	@Override
	public boolean draw(GL gl) {
		gl.glDisable(GL.GL_TEXTURE_2D);
		gl.glPushMatrix();
		//gl.glScalef(this.scale.x, this.scale.y, 1.0f);
		//System.out.println("scaleX: "+this.scale.x+"; scaleY: "+ this.scale.y);
		//gl.glScalef(0.5f, 0.5f, 1.0f);
		//gl.glTranslatef(this.pos.x, this.pos.y, spriteID*0.00001f);
		gl.glColor3f(color.x, color.y, color.z);
		gl.glLineWidth(2.0f);
		float radius;
		for(int i = 1; i < ringNumber; i++){
			radius = (float)Visualization.getRadiusOfRing(i);
			gl.glBegin(GL.GL_LINE_STRIP);
			for ( float angle = 0; angle <= 2*3.142; angle+=3.142/30)
			{
				float x = (float) (radius * Math.cos(angle));
				float z = (float) (radius * Math.sin(angle));

				//gl.glVertex2f(x/2, z/2);
				gl.glVertex2f(x, z);

			}
			float x = (float) (radius * Math.cos(2*3.142));
			float z = (float) (radius * Math.sin(2*3.142));
			gl.glVertex2f(x, z);
			gl.glEnd();
		}
		gl.glPopMatrix();

		gl.glEnable(GL.GL_TEXTURE_2D);
		return true;
	}

	@Override
	public boolean init(GL gl) {
		return true;
	}
	/**
	 * defines how many rings are shown
	 * @param ringNumber
	 */
	public static void setRingNumber(int ringNumber){
		Rings.ringNumber = ringNumber;
	}
}
